package com.survey.system.service.impl;

import java.util.List;

import com.survey.common.core.domain.entity.SysUser;
import com.survey.common.core.domain.model.LoginUser;
import com.survey.common.utils.DateUtils;
import com.survey.common.utils.SecurityUtils;
import com.survey.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.survey.system.mapper.SurIssueTypeMapper;
import com.survey.system.domain.SurIssueType;
import com.survey.system.service.ISurIssueTypeService;

/**
 * 问题类型Service业务层处理
 *
 * @author ruoyi
 * @date 2024-12-25
 */
@Service
public class SurIssueTypeServiceImpl implements ISurIssueTypeService {
    @Autowired
    private SurIssueTypeMapper surIssueTypeMapper;

    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询问题类型
     *
     * @param typeId 问题类型主键
     * @return 问题类型
     */
    @Override
    public SurIssueType selectSurIssueTypeByTypeId(Long typeId) {
        return surIssueTypeMapper.selectSurIssueTypeByTypeId(typeId);
    }

    /**
     * 查询问题类型列表
     *
     * @param surIssueType 问题类型
     * @return 问题类型
     */
    @Override
    public List<SurIssueType> selectSurIssueTypeList(SurIssueType surIssueType) {
        return surIssueTypeMapper.selectSurIssueTypeList(surIssueType);
    }

    /**
     * 新增问题类型
     *
     * @param surIssueType 问题类型
     * @return 结果
     */
    @Override
    public int insertSurIssueType(SurIssueType surIssueType) {
        return surIssueTypeMapper.insertSurIssueType(surIssueType);
    }

    /**
     * 修改问题类型
     *
     * @param surIssueType 问题类型
     * @return 结果
     */
    @Override
    public int updateSurIssueType(SurIssueType surIssueType) {
        surIssueType.setUpdateTime(DateUtils.getNowDate());
        return surIssueTypeMapper.updateSurIssueType(surIssueType);
    }

    /**
     * 批量删除问题类型
     *
     * @param typeIds 需要删除的问题类型主键
     * @return 结果
     */
    @Override
    public int deleteSurIssueTypeByTypeIds(Long[] typeIds) {
        return surIssueTypeMapper.deleteSurIssueTypeByTypeIds(typeIds);
    }

    /**
     * 删除问题类型信息
     *
     * @param typeId 问题类型主键
     * @return 结果
     */
    @Override
    public int deleteSurIssueTypeByTypeId(Long typeId) {
        return surIssueTypeMapper.deleteSurIssueTypeByTypeId(typeId);
    }

    @Override
    public List<SurIssueType> selectSurIssueTypeListAdmin(SurIssueType surIssueType) {
//        if (surIssueType.getSchoolId() == null) {
//            Long userId = SecurityUtils.getUserId();
//            SysUser sysUser = sysUserMapper.selectUserById(userId);
//            surIssueType.setSchoolId(sysUser.getSchoolId());
//        }
        return surIssueTypeMapper.selectSurIssueTypeList(surIssueType);
    }
}
